﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace Tile
{
    class Palleta
    {
        //Declaração de Variáveis
        Texture2D textura;
        Vector2 position;
        Rectangle size; 
        Vector2 velocity;  

        public Palleta(Texture2D textura, Vector2 position)
        {
            this.textura = textura;
            this.position = position;
            this.velocity = new Vector2(5,0);
            this.size = textura.Bounds;   
        }

        public void Update(GameWindow janela, List<Keys> teclas)
        {
            this.size.X = (int)position.X;
            this.size.Y = (int)position.Y;

            foreach (Keys tecla in teclas)
            {
                if (Keyboard.GetState().IsKeyDown(tecla) && tecla == Keys.Right)
                {
                    if (position.X > (janela.ClientBounds.Width - textura.Width) - 10)
                    {
                        position.X = (janela.ClientBounds.Width - textura.Width) - 10; 
                    }
                    position += velocity;   
                }

                if (Keyboard.GetState().IsKeyDown(tecla) && tecla == Keys.Left)
                {
                    if (position.X < 10)
                    {
                        position.X = 10; 
                    }
                    position -= velocity; 
                }
            }

        }

        public void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(textura, position, Color.White);  
        }

        public Vector2 GetPosition
        {
            get { return position; }
        }

        public Rectangle GetSize
        {
            get { return size; }
        }

    }
}
